home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / util / misc / LocaleTest.lha / LocaleTest / Developer / PTReplay / PTReplay.c next >
Encoding:
C/C++ Source or Header  |  1997-01-24  |  4.4 KB  |  110 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2.  *         Full source code of freeware utility called PTReplay.         *
  3.  *                                                                       *
  4.  * It utility lets easy way to play modules in protracker format with    *
  5.  * xpk compression support.                                              *
  6.  *                                                                       *
  7.  *  Usage: PTReplay MODULE_NAME                                          *
  8.  *     or  PTReplay STOP                                                 *
  9.  *     or  PTReplay ?                                                    *
  10.  *                                                                       *
  11.  *  For example: PTReplay start.mod                                      *
  12.  *                                                                       *
  13.  *  Requirements: xpkmaster.library version 2 or above,                  *
  14.  *                ptreplay.library version 4 or above.                   *
  15.  *                                                                       *
  16.  *  Note:  - For stop play use keyword STOP or send any break signal to  *
  17.  *           process which PTReplay was launched from.                   *
  18.  *                                                                       *
  19.  *  Author: Sergeev Oleg, Saint-Petersburg, Russia, 1997.                *
  20.  *                                                                       *
  21.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  22.  
  23. #define __USE_SYSBASE
  24. #include <proto/exec.h>
  25. #include <exec/types.h>
  26. #include <exec/memory.h>
  27.  
  28. #include <clib/dos_protos.h>
  29. #include <pragmas/dos_pragmas.h>
  30. #include <dos/rdargs.h>
  31. #define   MIN_DOS_VERSION 36L
  32.  
  33. #include <pragma/xpkmaster_lib.h>
  34. #include <xpk/xpk.h>
  35. #define MIN_XPK_VERSION 2L
  36.  
  37. #include <clib/ptreplay_protos.h>
  38. #include <pragmas/ptreplay_pragmas.h>
  39. #include <libraries/ptreplay.h>
  40. #define   MIN_PTREPLAY_VERSION 4L
  41.  
  42. #define TEMPLATE   "MODULE,STOP/S"
  43. #define ALL_BREAKF (SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F)
  44.  
  45. struct XpkData
  46. {
  47.   ULONG  outputsize;
  48.   ULONG  buffersize;
  49.   STRPTR buffer;
  50. };
  51.  
  52. enum { ARG_MODULE, ARG_STOP, ARG_TERMINATOR };
  53.  
  54. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
  55. ///
  56. LONG main (void)
  57. {
  58.   struct ExecBase *SysBase = (*((struct ExecBase **)4));
  59.   struct Library  *DOSBase, *XpkBase, *PTReplayBase;
  60.   struct RDArgs   *rdargs;
  61.   struct XpkData   xpkd;
  62.   struct Module   *module;
  63.   struct Task     *task;
  64.   UBYTE  taskname[] = "PTReplay 1.1 by Sergeev O.V.";
  65.   STRPTR args[ARG_TERMINATOR];
  66.  
  67.   if (DOSBase = OpenLibrary (DOSNAME, MIN_DOS_VERSION))
  68.     {
  69.       if (XpkBase = OpenLibrary (XPKNAME, MIN_XPK_VERSION))
  70.         {
  71.           if (PTReplayBase = OpenLibrary (PTREPLAYNAME, MIN_PTREPLAY_VERSION))
  72.             {
  73.               args[ARG_MODULE] = NULL;
  74.               args[ARG_STOP] = FALSE;
  75.               if (rdargs = ReadArgs (TEMPLATE, (LONG *)args, NULL))
  76.                 {
  77.                   if ((args[ARG_STOP]) && (task = FindTask (taskname)))
  78.                     Signal (task, ALL_BREAKF);
  79.                   else if (! XpkUnpackTags (XPK_InName,       args[ARG_MODULE],
  80.                                             XPK_OutMemType,   MEMF_CHIP,
  81.                                             XPK_GetOutBuf,    &xpkd.buffer,
  82.                                             XPK_GetOutLen,    &xpkd.outputsize,
  83.                                             XPK_GetOutBufLen, &xpkd.buffersize,
  84.                                             XPK_PassThru,     TRUE,
  85.                                             TAG_DONE))
  86.                     {
  87.                       if (module = PTSetupMod (xpkd.buffer))
  88.                         {
  89.                           if (PTPlay (module))
  90.                             {
  91.                               (FindTask(NULL))->tc_Node.ln_Name = taskname;
  92.                               Wait (ALL_BREAKF);
  93.                               PTFade (module, 2);
  94.                               PTStop (module);
  95.                             }
  96.                           PTFreeMod (module);
  97.                         }
  98.                       FreeMem (xpkd.buffer, xpkd.buffersize);
  99.                     }
  100.                   FreeArgs (rdargs);
  101.                 }
  102.               CloseLibrary (PTReplayBase);
  103.             }
  104.           CloseLibrary (XpkBase);
  105.         }
  106.       CloseLibrary (DOSBase);
  107.     }
  108.   return (0L);
  109. }
  110.